import cv2
import numpy as np

capture = cv2.VideoCapture(1)
capture.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc('M', 'J', 'P', 'G'))
capture.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
capture.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)

capture.set(cv2.CAP_PROP_FPS, 120)
while True:
    if not capture.isOpened():
        print("无法找到摄像头")
        break
    ret, frame = capture.read()
    if not ret:
        continue

    cv2.imshow('img', frame)
    key = cv2.waitKey(1)
    if key == 27:
        break

capture.release()
cv2.destroyAllWindows()
